package com.xuxin.pda.presenter;

import com.xuxin.pda.bean.BaseBean;
import com.xuxin.pda.bean.LoginBean;
import com.xuxin.pda.contract.LoginContract;
import com.xuxin.pda.model.LoginModel;

/**
 * Created by xu_xin
 * Created on 2020/12/24 0024
 */
public class LoginPresenter implements LoginContract.Presenter {
    private final LoginModel model;
    private final LoginContract.View view;

    public LoginPresenter(LoginContract.View view) {
        this.view = view;
        model = new LoginModel();
    }

    @Override
    public void login(String code) {
        if (null != model) {
            model.login(this, code);
        }
    }

    @Override
    public void onSuccess(LoginBean loginBean) {
        if (null != view) {
            view.onSuccess(loginBean);
        }
    }

    /**
     * 以下内容复用
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}